package com.bxait;

import com.bxait.utils.ESClientSingle;
import jdk.nashorn.internal.runtime.logging.Logger;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * @author Chen
 * @description: 删除es索引
 * @ClassName ESTest_Client
 * @create 2023-04-08 16:16
 * @Version 1.0
 */
@Logger
public class ESTest_Index_Delete {

    public static void main(String[] args) throws IOException {
        // 创建ES的客户端
        RestHighLevelClient client = ESClientSingle.getInstant();
        // 删除索引
        DeleteIndexRequest request = new DeleteIndexRequest("user2");
        AcknowledgedResponse response = client.indices().delete(request, RequestOptions.DEFAULT);
        // 响应状态
        boolean acknowledged = response.isAcknowledged();
        System.out.println("-------------------------------->> "+ acknowledged);
        // 关闭es客户端
        client.close();
    }

}
